package leetcode_2301_2400;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class LeeCode_2325 {
    public static void main(String[] args) {
        System.out.println(decodeMessage("the quick brown fox jumps over the lazy dog", "vkbs bs t suepuv"));
    }
    private static String decodeMessage(String key, String message) {
        char c = 'a';
        Map<Character, Character> map = new HashMap<>();
        for (int i = 0; i < key.length(); i++) {
            char c0 = key.charAt(i);
            if (c0 == ' ')
                continue;
            if (!map.containsKey(c0)){
                map.put(c0, c++);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < message.length(); i++) {
            char c0 = message.charAt(i);
            sb.append(map.getOrDefault(c0, c0));
        }
        return sb.toString();
    }
}
